﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SmartCollection
{
    class Afamilyvn
    {
        SmartCollectionLoad smartLoad = new SmartCollectionLoad();
        public List<NewsDetails> Check()
        {
         
            List<Menu> ListMenu = new List<Menu>();
            List<NewsDetails> ListDetail = new List<NewsDetails>();
            List<News> ListNews = new List<News>();
            List<NumberPage> ListPage = new List<NumberPage>();
            string urlGoc = "http://afamily.vn";
            ListMenu = smartLoad.LoadMenu("http://afamily.vn/dep.chn","//ul[@class='mgt5']//li","",urlGoc);




    

           for (int i = 0; i < ListMenu.Count(); i++)
           {
               ListPage = smartLoad.LoadPage(ListMenu[i], "//div[@class='paging fl mgb20']//a", "http://afamily.vn/",urlGoc);
               for (int j = 0; j < ListPage.Count(); j++)
               {
               
                   ListDetail.AddRange( smartLoad.LoadHomeNews(ListPage[j], "//div[@class='list-news1']//div[@class='box-x2']", "", "//div//h2//a", "//div//p", "//div//a", "http://afamily.vn/",urlGoc));
                   ListDetail.AddRange(smartLoad.LoadHomeNews(ListPage[j], "//div[@class='list-news1']//div[@class='box-x1']", "", "//h2//a", "//p", "//a", "http://afamily.vn/",urlGoc));
                   ListDetail.AddRange(smartLoad.LoadHomeNews(ListPage[j], "//div[@class='list-news1']//div[@class='box-x3']", "", "//div//h2//a", "//div//p", "//div//a", "http://afamily.vn/", urlGoc));



                   for (int k = 0; k < ListDetail.Count(); k++)
                   {
                      
                       ListDetail.Add(smartLoad.LoadNews(ListDetail[k], "//div[@class='detail_content fl mgt15']"));
                       
                       //if (dem == 30)
                       //    break;
                   }
                 

                   //if (dem == 30)
                   //    break;
               }
               //if (dem == 30)
               //    break;
              
           }
            System.Windows.Forms.MessageBox.Show("\nThanh cong!");
            //if (dem == 0)
            //{
            //    MessageBox.Show("\nKhong co san pham moi!");
            //}
            //else MessageBox.Show("\nCo "+dem + " san pham moi");


            return ListDetail;
        
        
        
        }

        //public void Update()
        //{

        //    List<Menu> ListMenu = new List<Menu>();
        //    List<NewsDetails> ListDetail = new List<NewsDetails>();

        //    List<NumberPage> ListPage = new List<NumberPage>();
        //    string urlGoc = "http://afamily.vn";
        //    ListMenu = smartLoad.LoadMenu("http://afamily.vn/dep.chn", "//ul[@class='mgt5']//li", "", urlGoc);






        //    for (int i = 0; i < ListMenu.Count(); i++)
        //    {
        //        ListPage = smartLoad.LoadPage(ListMenu[i], "//div[@class='paging fl mgb20']//a", "http://afamily.vn/", urlGoc);
        //        for (int j = 0; j < ListPage.Count(); j++)
        //        {

        //            ListDetail.AddRange(smartLoad.LoadUpdateNewHomeNews(ListPage[j], "//div[@class='list-news1']//div[@class='box-x2']", "", "//div//h2//a", "//div//p", "//div//a", "http://afamily.vn/", urlGoc, "//div//span"));
        //            ListDetail.AddRange(smartLoad.LoadUpdateNewHomeNews(ListPage[j], "//div[@class='list-news1']//div[@class='box-x1']", "", "//h2//a", "//p", "//a", "http://afamily.vn/", urlGoc,"//span"));
        //            ListDetail.AddRange(smartLoad.LoadUpdateNewHomeNews(ListPage[j], "//div[@class='list-news1']//div[@class='box-x3']", "", "//div//h2//a", "//div//p", "//div//a", "http://afamily.vn/", urlGoc,"//div//span"));



        //            for (int k = 0; k < ListDetail.Count(); k++)
        //            {
        //                smartLoad.LoadNews(ListDetail[k], "//div[@class='detail_content fl mgt15']");

        //                //if (dem == 30)
        //                //    break;
        //            }


        //            //if (dem == 30)
        //            //    break;
        //        }
        //        //if (dem == 30)
        //        //    break;

        //    }
        //    System.Windows.Forms.MessageBox.Show("\nThanh cong!");
        //    //if (dem == 0)
        //    //{
        //    //    MessageBox.Show("\nKhong co san pham moi!");
        //    //}
        //    //else MessageBox.Show("\nCo "+dem + " san pham moi");






        //}

    
    }
}
